<?php
use yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
$this->title = '下载日志';
?>
<?= Html::cssFile('./assets/date/bootstrap-datetimepicker.min.css')?>
<div class="container">
    <div class="row">
        <?php echo $this->render('_leftnav');?>
        <div class="col-md-10">
          <div class="page-header clearfix">
            <h1 class="pull-left">下载日志</h1>
            <div class="pull-right">
            </div>
          </div>
<div class="well well-sm">
    <?php
            $form = ActiveForm::begin([
            'action' => ['download/logs'],
            'method'=>'post',
            'options' => [
                'id' => 'login-record-search-form',
                'class'=>'form-inline',
                ]	
            ]);	
     ?>    
    <div class="form-group">
      <?php 
            $session = Yii::$app->session;
            $session->open();
			$user=['user_name' => '用户名','user_email' => '用户邮箱'];
	  ?>
	  <?= Html::dropDownList('usertype',$session->get('log_usertype')?$session->get('log_usertype'):'user_name',ArrayHelper::map($user,'id', 'orderStatus'), ['class' => 'form-control']);?>     
    </div>

    <div class="form-group">
      <?= Html::input('text', 'username',$session->get('log_username')?$session->get('log_username'):'',['class' => 'form-control','id' =>'keyword','placeholder' => '请输入关键词']) ?>
    </div>

    <div class="form-group">
        <?= Html::input('text', 'startdatetime',$session->get('log_startdatetime')?$session->get('log_startdatetime'):'',['class' => ['form-control','form-datetime'],'placeholder' => '起始时间','id'=>'startDate']) ?>
    </div>

    <div class="form-group">
        <?= Html::input('text', 'enddatetime',$session->get('log_enddatetime')?$session->get('log_enddatetime'):'',['class' => ['form-control','form-datetime'],'id' =>'endDate','placeholder' => '结束时间',]) ?>
    </div>
    <span></span>
    <?= Html::submitButton('搜索', ['class' => 'btn btn-primary']) ?>
    <a class='btn btn-primary' href='<?= Url::toRoute(['download/logs','remove_where'=>1]);?>'>清空条件</a>
<?php ActiveForm::end(); ?> 
    <?= Html::jsFile('./assets/date/bootstrap-datetimepicker.min.js')?>
    <?= Html::jsFile('./assets/date/bootstrap-datetimepicker.fr.js')?>
    <script type="text/javascript">
    $('.form-datetime').datetimepicker({
		autoclose: 1,//当选择一个日期之后是否立即关闭此日期时间选择器
		todayHighlight: 1,//如果为true, 高亮当前日期
		startView: 2,//日期时间选择器打开之后首先显示的视图  控制样式  0~4 
	});
    </script>
</div>

<table id="teacher-table" class="table table-striped table-hover" data-search-form="#user-search-form">
  <thead>
    <tr>
      <th>用户名</th>
      <th>邮箱</th>
      <th>登录IP</th>
      <th>登录时间</th>
      <th>操作简述</th>
    </tr>
  </thead>
      <tbody>
      <?php foreach ($info as $key => $val):?>
           <tr id="user-table-tr-<?=$val['log_id']?>">
            <td width='10%'>
                <strong>
                <a href="javascript:void(0);" role="show-user" data-toggle="modal" data-target="#modal" data-url=""><?= Html::encode($val['user_name'])?></a>
        	   </strong>
            </td>
            <td>
                <strong>
                <a href="javascript:void(0);" role="show-user" data-toggle="modal" data-target="#modal" data-url=""><?= Html::encode($val['user_email'])?></a>
        	   </strong>
            </td>
            <td>
                <span><?= Html::encode($val['ip_address'])?></span>
            </td>
            <td>
                <span class="text-sm"><?= date('Y-m-d H:i:s',$val['log_addtime']) ?></span>
            </td>
            <td>
                <span><?= Html::encode($val['log_info'])?></span>                 
            </td>
           </tr>    
       <?php endforeach;?>
      </tbody>
    </table>
        <div style='margin-left:250px;'>
            <?php echo LinkPager::widget([
    				'pagination' => $paging,
    				'firstPageLabel'=>"首页",
    				'prevPageLabel'=>'上一页',
    				'nextPageLabel'=>'下一页',
    				'lastPageLabel'=>'尾页',
    			]);?>
        </div>
        </div>
        
          </div>
  </div>